<html>
<head>
<title>RChart, User Guide</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" leftmargin="35">
<h3>RCHART, User Guide</h3>
<p><font face="Arial, Helvetica, sans-serif" size="-1"><i>Copyright 2007, J4L 
  Components (http://www.java4less.com)</i></font> <br>
  <a href="tutorialcontents.html">Go bak to contents</a></p>
<hr>
<h3><font face="Arial, Helvetica, sans-serif">RChart plugins</font></h3>
<ul>
  <li><a href="#batik"><font face="Arial, Helvetica, sans-serif" size="-1">Batik 
    integration. Generation of SVG image files. </font></a></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1"><a href="#fop">FOP Integration. 
    Generation of PDF files.</a></font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1"><a href="#jsp">JSP Tag 
    Library</a></font></li>
</ul>
<p>&nbsp;</p>
<h4><font face="Arial, Helvetica, sans-serif" size="-1"><b><a name="batik"></a>Batik 
  integration. Generation of SVG image files.</b></font></h4>
<p><font face="Arial, Helvetica, sans-serif" size="-1">You can use RChart to generate 
  SVG images. In order to do you you need:</font></p>
<ul>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">add rchart2.jar and 
    rchart_batik.jar to your classpath</font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">download apache Batik 
    1.6 from <a href="http://xmlgraphics.apache.org/batik/">http://xmlgraphics.apache.org/batik</a>/</font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">add at least the following 
    Batik files to your classpath: batik-svggen.jar, batik-svg-dom.jar, batik-dom.jar, 
    batik-xml.jar, batik-swing.jar, batik-awt-util.jar, batik-ext.jar,batik-extension.jar, 
    xml-apis.jar and batik-util.jar.</font></li>
</ul>
<p><font face="Arial, Helvetica, sans-serif" size="-1">You can now create SVG 
  output using the following code:</font></p>
<blockquote> 
  <blockquote> 
    <blockquote> 
      <p><font face="Courier New, Courier, mono" size="-1">// FIRST CREATE A CHART<br>
        ChartLoader cha=new ChartLoader(null);<br>
        cha.setParameter(&quot;TITLECHART&quot;,&quot;Sales 2006&quot;);<br>
        cha.setParameter(&quot;LEGEND&quot;,&quot;TRUE&quot;); <br>
        cha.setParameter(&quot;XLABEL&quot;,&quot;Month&quot;); <br>
        cha.setParameter(&quot;YLABEL&quot;,&quot;Million $&quot;); <br>
        cha.setParameter(&quot;XAXIS_LABELS&quot;,&quot;June|July|Aug.|Sept.|Oct.|Nov.|Dec.&quot;);<br>
        cha.setParameter(&quot;SERIE_1&quot;,&quot;Products&quot;);<br>
        cha.setParameter(&quot;SERIE_2&quot;,&quot;Services&quot;);<br>
        cha.setParameter(&quot;SERIE_STYLE_1&quot;,&quot;0.2|RED|LINE&quot;);<br>
        cha.setParameter(&quot;SERIE_FONT_1&quot;,&quot;Arial|PLAIN|8&quot;);<br>
        cha.setParameter(&quot;SERIE_FONT_2&quot;,&quot;Arial|PLAIN|8&quot;);<br>
        cha.setParameter(&quot;SERIE_COLOR_1&quot;,&quot;RED&quot;);<br>
        cha.setParameter(&quot;SERIE_COLOR_2&quot;,&quot;BLUE&quot;);<br>
        cha.setParameter(&quot;SERIE_POINT_COLOR_1&quot;,&quot;RED&quot;);<br>
        cha.setParameter(&quot;SERIE_POINT_COLOR_2&quot;,&quot;BLUE&quot;);<br>
        cha.setParameter(&quot;SERIE_POINT_1&quot;,&quot;true&quot;);<br>
        cha.setParameter(&quot;SERIE_POINT_2&quot;,&quot;true&quot;);<br>
        cha.setParameter(&quot;SERIE_STYLE_2&quot;,&quot;0.2|BLUE|LINE&quot;);<br>
        cha.setParameter(&quot;SERIE_DATA_1&quot;,&quot;12|43|50|45|30|32|42&quot;);<br>
        cha.setParameter(&quot;SERIE_DATA_2&quot;,&quot;20|41|48|39|36|34|50&quot;);<br>
        cha.setParameter(&quot;SERIE_TYPE_1&quot;,&quot;LINE&quot;);<br>
        cha.setParameter(&quot;SERIE_TYPE_2&quot;,&quot;LINE&quot;);<br>
        cha.setParameter(&quot;CHART_BORDER&quot;,&quot;0.2|BLACK|LINE&quot;);<br>
        cha.setParameter(&quot;CHART_FILL&quot;,&quot;LIGHTGRAY&quot;);<br>
        cha.setParameter(&quot;BIG_TICK_INTERVALX&quot;,&quot;1&quot;);<br>
        cha.setParameter(&quot;BIG_TICK_INTERVALY&quot;,&quot;10&quot;);<br>
        cha.setParameter(&quot;YSCALE_MIN&quot;,&quot;0&quot;);<br>
        cha.setParameter(&quot;LEGEND_BORDER&quot;,&quot;0.2|BLACK|LINE&quot;);<br>
        cha.setParameter(&quot;LEGEND_FILL&quot;,&quot;WHITE&quot;);<br>
        cha.setParameter(&quot;XAXIS_GRID&quot;,&quot;0.2|WHITE|DASHED&quot;);<br>
        cha.setParameter(&quot;YAXIS_GRID&quot;,&quot;0.2|WHITE|DASHED&quot;);<br>
        cha.setParameter(&quot;XAXIS_TICKATBASE&quot;,&quot;true&quot;); <br>
        cha.setParameter(&quot;CHART_FILL&quot;,&quot;YELLOW&quot;);<br>
        cha.setParameter(&quot;YLABEL_VERTICAL&quot;,&quot;TRUE&quot;);<br>
        /* process parameters and create chart*/<br>
        Chart c=cha.build(false,true);<br>
        c.setWidth(300);<br>
        c.setHeight(300);</font></p>
      <p>&nbsp; </p>
      <p><font face="Courier New, Courier, mono" size="-1">// OUTPUT CHART TO 
        A SVG file<br>
        FileOutputStream os=new FileOutputStream(&quot;chart.svg&quot;);<br>
        ChartImage image=new ChartBatikImage(300,300);<br>
        ChartGraphics g=null;<br>
        g=image.getGraphics();<br>
        c.doubleBuffering=false;<br>
        c.paint(g); <br>
        image.saveToStream(null,os); <br>
        c.dispose();</font></p>
    </blockquote>
  </blockquote>
</blockquote>
<p>&nbsp;</p>
<p><font face="Arial, Helvetica, sans-serif" size="-1">The following code shows 
  you how to create a SVG image in a JSP page:</font></p>
<blockquote> 
  <blockquote> 
    <blockquote>
      <p><font face="Courier New, Courier, mono" size="-1">&lt;%@ page import=&quot;com.java4less.rchart.*&quot; 
        %&gt;<br>
        &lt;%@ page import=&quot;com.java4less.rchart.gc.*&quot; %&gt;<br>
        &lt;%@ page import=&quot;com.java4less.rchart.gc.svg.*&quot; %&gt;</font></p>
      <p><font face="Courier New, Courier, mono" size="-1">&lt;%</font></p>
      <p><font face="Courier New, Courier, mono" size="-1">response.setContentType(&quot;image/svg&quot;); 
        // SVG output<br>
        response.setDateHeader (&quot;Expires&quot;,0);<br>
        // get output stream<br>
        java.io.OutputStream outb=response.getOutputStream();<br>
        </font></p>
      <p><font face="Courier New, Courier, mono" size="-1">// FIRST CREATE A CHART<br>
        ChartLoader cha=new ChartLoader(null);<br>
        cha.setParameter(&quot;TITLECHART&quot;,&quot;Sales 2006&quot;);<br>
        cha.setParameter(&quot;LEGEND&quot;,&quot;TRUE&quot;); <br>
        cha.setParameter(&quot;XLABEL&quot;,&quot;Month&quot;); <br>
        cha.setParameter(&quot;YLABEL&quot;,&quot;Million $&quot;); <br>
        cha.setParameter(&quot;XAXIS_LABELS&quot;,&quot;June|July|Aug.|Sept.|Oct.|Nov.|Dec.&quot;);<br>
        cha.setParameter(&quot;SERIE_1&quot;,&quot;Products&quot;);<br>
        cha.setParameter(&quot;SERIE_2&quot;,&quot;Services&quot;);<br>
        cha.setParameter(&quot;SERIE_STYLE_1&quot;,&quot;0.2|RED|LINE&quot;);<br>
        cha.setParameter(&quot;SERIE_FONT_1&quot;,&quot;Arial|PLAIN|8&quot;);<br>
        cha.setParameter(&quot;SERIE_FONT_2&quot;,&quot;Arial|PLAIN|8&quot;);<br>
        cha.setParameter(&quot;SERIE_COLOR_1&quot;,&quot;RED&quot;);<br>
        cha.setParameter(&quot;SERIE_COLOR_2&quot;,&quot;BLUE&quot;);<br>
        cha.setParameter(&quot;SERIE_POINT_COLOR_1&quot;,&quot;RED&quot;);<br>
        cha.setParameter(&quot;SERIE_POINT_COLOR_2&quot;,&quot;BLUE&quot;);<br>
        cha.setParameter(&quot;SERIE_POINT_1&quot;,&quot;true&quot;);<br>
        cha.setParameter(&quot;SERIE_POINT_2&quot;,&quot;true&quot;);<br>
        cha.setParameter(&quot;SERIE_STYLE_2&quot;,&quot;0.2|BLUE|LINE&quot;);<br>
        cha.setParameter(&quot;SERIE_DATA_1&quot;,&quot;12|43|50|45|30|32|42&quot;);<br>
        cha.setParameter(&quot;SERIE_DATA_2&quot;,&quot;20|41|48|39|36|34|50&quot;);<br>
        cha.setParameter(&quot;SERIE_TYPE_1&quot;,&quot;LINE&quot;);<br>
        cha.setParameter(&quot;SERIE_TYPE_2&quot;,&quot;LINE&quot;);<br>
        cha.setParameter(&quot;CHART_BORDER&quot;,&quot;0.2|BLACK|LINE&quot;);<br>
        cha.setParameter(&quot;CHART_FILL&quot;,&quot;LIGHTGRAY&quot;);<br>
        cha.setParameter(&quot;BIG_TICK_INTERVALX&quot;,&quot;1&quot;);<br>
        cha.setParameter(&quot;BIG_TICK_INTERVALY&quot;,&quot;10&quot;);<br>
        cha.setParameter(&quot;YSCALE_MIN&quot;,&quot;0&quot;);<br>
        cha.setParameter(&quot;LEGEND_BORDER&quot;,&quot;0.2|BLACK|LINE&quot;);<br>
        cha.setParameter(&quot;LEGEND_FILL&quot;,&quot;WHITE&quot;);<br>
        cha.setParameter(&quot;XAXIS_GRID&quot;,&quot;0.2|WHITE|DASHED&quot;);<br>
        cha.setParameter(&quot;YAXIS_GRID&quot;,&quot;0.2|WHITE|DASHED&quot;);<br>
        cha.setParameter(&quot;XAXIS_TICKATBASE&quot;,&quot;true&quot;); <br>
        cha.setParameter(&quot;CHART_FILL&quot;,&quot;YELLOW&quot;);<br>
        cha.setParameter(&quot;YLABEL_VERTICAL&quot;,&quot;TRUE&quot;);<br>
        /* process parameters and create chart*/<br>
        Chart c=cha.build(false,true);<br>
        c.setWidth(300);<br>
        c.setHeight(300);</font></p>
      <p>&nbsp;</p>
      <p><font face="Courier New, Courier, mono" size="-1">// OUTPUT CHART AS 
        SVG </font></p>
      <p><font face="Courier New, Courier, mono" size="-1">ChartImage image=new 
        ChartBatikImage(300,300);<br>
        ChartGraphics g=null;<br>
        g=image.getGraphics();<br>
        c.doubleBuffering=false;<br>
        c.paint(g); <br>
        image.saveToStream(null,outb); <br>
        c.dispose();<br>
        %&gt;</font></p>
    </blockquote>
  </blockquote>
</blockquote>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><font face="Arial, Helvetica, sans-serif" size="-1"><b><a name="fop"></a>FOP 
  integration. Generation of PDF files.</b></font></p>
<p><font face="Arial, Helvetica, sans-serif" size="-1">RChart can be used together 
  with <b>Apache FOP</b> to include charts in your PDF files.</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="-1">In order to generate charts 
  in pdf files you need:</font></p>
<ul>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">add rchart2.jar, rchart_batik.jar 
    and rchart_fop.jar to your classpath</font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">download Apache FOP 
    version 0.93 from <a href="http://xmlgraphics.apache.org/fop/">http://xmlgraphics.apache.org/fop/</a></font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">add the following Apache 
    jars to your classpath: xmlgraphics-commons-1.1.jar, xml-apis-1.3.02.jar, 
    xercesImpl-2.7.1.jar, xalan-2.7.0.jar, servlet-2.2.jar, serializer-2.7.0.jar, 
    commons-logging-1.0.4.jar, commons-io-1.1.jar, batik-all-1.6.jar , avalon-framework-4.2.0.jar 
    and fop.jar.</font></li>
</ul>
<p><font face="Arial, Helvetica, sans-serif" size="-1">After you have installed 
  all required jar files you must create a FO file (please refer to the APACHE 
  FOP documentation). For example, the following file includes a chart:</font></p>
<blockquote> 
  <blockquote> 
    <p><font face="Courier New, Courier, mono" size="-1">&lt;fo:root xmlns:fo=&quot;http://www.w3.org/1999/XSL/Format&quot; 
      xmlns:svg=&quot;http://www.w3.org/2000/svg&quot;&gt;<br>
      &lt;fo:layout-master-set&gt;<br>
      &lt;fo:simple-page-master master-name=&quot;one&quot;&gt;<br>
      &lt;fo:region-body margin-top=&quot;25pt&quot; margin-bottom=&quot;25pt&quot; 
      margin-left=&quot;50pt&quot; margin-right=&quot;50pt&quot; /&gt;<br>
      &lt;/fo:simple-page-master&gt;<br>
      &lt;/fo:layout-master-set&gt;<br>
      &lt;fo:page-sequence master-reference=&quot;one&quot;&gt;<br>
      &lt;fo:flow flow-name=&quot;xsl-region-body&quot;&gt;<br>
      &lt;fo:block&gt;<br>
      This is my chart</font></p>
    <p><font face="Courier New, Courier, mono" size="-1"><br>
      &lt;fo:instream-foreign-object &gt;<br>
      </font></p>
    <blockquote> 
      <p><font face="Courier New, Courier, mono" size="-1">&lt;rchart xmlns=&quot;http://java4less.com/rchart/fop&quot; 
        mode=&quot;inline&quot;&gt;<br>
        &lt;param name=&quot;WIDTH&quot;&gt;350&lt;/param&gt;<br>
        &lt;param name=&quot;HEIGHT&quot;&gt;350&lt;/param&gt;<br>
        &lt;param name=&quot;TITLECHART&quot;&gt;Sales 2000&lt;/param&gt;<br>
        &lt;param name=&quot;LEGEND&quot;&gt;TRUE&lt;/param&gt; <br>
        &lt;param name=&quot;XLABEL&quot;&gt;Month&lt;/param&gt; <br>
        &lt;param name=&quot;YLABEL&quot;&gt;Million $&lt;/param&gt; <br>
        &lt;param name=&quot;XAXIS_LABELS&quot;&gt;June|July|Aug.|Sept.|Oct.|Nov.|Dec.&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_1&quot;&gt;Products&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_2&quot;&gt;Services&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_STYLE_1&quot;&gt;0.2|RED|LINE&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_FONT_1&quot;&gt;Arial|PLAIN|8&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_FONT_2&quot;&gt;Arial|PLAIN|8&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_COLOR_1&quot;&gt;RED&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_COLOR_2&quot;&gt;BLUE&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_POINT_COLOR_1&quot;&gt;RED&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_POINT_COLOR_2&quot;&gt;BLUE&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_POINT_1&quot;&gt;true&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_POINT_2&quot;&gt;true&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_STYLE_2&quot;&gt;0.2|BLUE|LINE&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_DATA_1&quot;&gt;12|43|50|45|30|32|42&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_DATA_2&quot;&gt;20|41|48|39|36|34|50&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_TYPE_1&quot;&gt;LINE&lt;/param&gt;<br>
        &lt;param name=&quot;SERIE_TYPE_2&quot;&gt;LINE&lt;/param&gt;<br>
        &lt;param name=&quot;CHART_BORDER&quot;&gt;0.2|BLACK|LINE&lt;/param&gt;<br>
        &lt;param name=&quot;CHART_FILL&quot;&gt;YELLOW&lt;/param&gt;<br>
        &lt;param name=&quot;BIG_TICK_INTERVALX&quot;&gt;1&lt;/param&gt;<br>
        &lt;param name=&quot;BIG_TICK_INTERVALY&quot;&gt;10&lt;/param&gt;<br>
        &lt;param name=&quot;YSCALE_MIN&quot;&gt;0&lt;/param&gt;<br>
        &lt;param name=&quot;LEGEND_BORDER&quot;&gt;0.2|BLACK|LINE&lt;/param&gt;<br>
        &lt;param name=&quot;LEGEND_FILL&quot;&gt;WHITE&lt;/param&gt;<br>
        &lt;param name=&quot;XAXIS_GRID&quot;&gt;0.2|WHITE|DASHED&lt;/param&gt;<br>
        &lt;param name=&quot;YAXIS_GRID&quot;&gt;0.2|WHITE|DASHED&lt;/param&gt;<br>
        &lt;param name=&quot;XAXIS_TICKATBASE&quot;&gt;true&lt;/param&gt; <br>
        &lt;/rchart&gt; </font></p>
    </blockquote>
    <p><font face="Courier New, Courier, mono" size="-1">&lt;/fo:instream-foreign-object&gt;<br>
      </font></p>
    <p><font face="Courier New, Courier, mono" size="-1">&lt;/fo:block&gt;<br>
      </font><font face="Courier New, Courier, mono" size="-1">&lt;/fo:flow&gt;<br>
      &lt;/fo:page-sequence&gt;<br>
      &lt;/fo:root&gt;</font></p>
    </blockquote>
</blockquote>
<p>&nbsp;</p>
<p><font face="Arial, Helvetica, sans-serif" size="-1">As you can see the chart 
  section of the file has the following format</font></p>
<p>&nbsp;</p>
<blockquote> 
  <blockquote> 
    <p><font face="Courier New, Courier, mono" size="-1">&lt;fo:instream-foreign-object 
      &gt;<br>
      </font></p>
    <blockquote> 
      <p><font face="Courier New, Courier, mono" size="-1">&lt;rchart xmlns=&quot;http://java4less.com/rchart/fop&quot; 
        mode=&quot;inline&quot;&gt;<br>
        </font></p>
      <blockquote> 
        <p>// ADD YOUR CHART PARAMETERS HERE<br>
          <font face="Courier New, Courier, mono" size="-1">&lt;param name=&quot;WIDTH&quot;&gt;350&lt;/param&gt; 
          <br>
          </font><font face="Courier New, Courier, mono" size="-1">.....</font></p>
        </blockquote>
      <p><font face="Courier New, Courier, mono" size="-1">&lt;/rchart&gt; </font></p>
    </blockquote>
    <p><font face="Courier New, Courier, mono" size="-1">&lt;/fo:instream-foreign-object&gt;</font></p>
  </blockquote>
</blockquote>
    
<p>&nbsp;</p>
<p><font face="Arial, Helvetica, sans-serif" size="-1">Store the FO definition 
  in a file called chart.fo. You can now use the following code to convert the 
  FO file to PDF:</font></p>
<blockquote> 
  <blockquote> 
    <p><font face="Courier New, Courier, mono" size="-1">import java.io.BufferedOutputStream;<br>
      import java.io.File;<br>
      import java.io.FileOutputStream;<br>
      import java.io.OutputStream;<br>
      import javax.xml.transform.Transformer;<br>
      import javax.xml.transform.TransformerFactory;<br>
      import javax.xml.transform.Source;<br>
      import javax.xml.transform.Result;<br>
      import javax.xml.transform.stream.StreamSource;<br>
      import javax.xml.transform.sax.SAXResult;<br>
      import org.apache.fop.apps.FOUserAgent;<br>
      import org.apache.fop.apps.Fop;<br>
      import org.apache.fop.apps.FopFactory;<br>
      import org.apache.fop.apps.MimeConstants;<br>
      <br>
      public class Chart2PDF {<br>
      <br>
      public static void main(String[] args) {<br>
      try {<br>
      <br>
      FopFactory fopFactory = FopFactory.newInstance();<br>
      System.out.println(&quot;Chart2PDF\n&quot;);<br>
      <br>
      // files <br>
      File fofile = new File(&quot;chart.fo&quot;);<br>
      File pdffile = new File(&quot;Chart.pdf&quot;);<br>
      <br>
      OutputStream out = null; <br>
      FOUserAgent foUserAgent = fopFactory.newFOUserAgent();<br>
      <br>
      // Setup output stream. <br>
      out = new FileOutputStream(pdffile);<br>
      out = new BufferedOutputStream(out);<br>
      Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);<br>
      // Setup JAXP using identity transformer<br>
      TransformerFactory factory = TransformerFactory.newInstance();<br>
      Transformer transformer = factory.newTransformer(); // identity transformer<br>
      <br>
      // Setup input stream<br>
      Source src = new StreamSource(fofile);<br>
      // Resulting SAX events (the generated FO) must be piped through to FOP<br>
      Result res = new SAXResult(fop.getDefaultHandler());<br>
      <br>
      transformer.transform(src, res);<br>
      <br>
      out.close();<br>
      System.out.println(&quot;End\n&quot;);<br>
      } catch (Exception e) {<br>
      e.printStackTrace();<br>
      }<br>
      <br>
      }<br>
      }</font></p>
  </blockquote>
</blockquote>
<p><font face="Arial, Helvetica, sans-serif" size="-1">You can also use the code 
  in a JSP page and send the PDF file to the browser:</font></p>
<blockquote> 
  <blockquote> 
    <p><br>
      <font face="Courier New, Courier, mono" size="-1">&lt;%@ page import=&quot;java.io.*&quot; 
      %&gt;<br>
      &lt;%@ page import=&quot;javax.xml.transform.Transformer&quot; %&gt;<br>
      &lt;%@ page import=&quot;javax.xml.transform.TransformerFactory&quot; %&gt;<br>
      &lt;%@ page import=&quot;javax.xml.transform.Source&quot; %&gt;<br>
      &lt;%@ page import=&quot;javax.xml.transform.Result&quot; %&gt;<br>
      &lt;%@ page import=&quot;javax.xml.transform.stream.StreamSource&quot; %&gt;<br>
      &lt;%@ page import=&quot;javax.xml.transform.sax.SAXResult&quot; %&gt;<br>
      &lt;%@ page import=&quot;org.apache.fop.apps.FOUserAgent&quot; %&gt;<br>
      &lt;%@ page import=&quot;org.apache.fop.apps.Fop&quot; %&gt;<br>
      &lt;%@ page import=&quot;org.apache.fop.apps.FopFactory&quot; %&gt;<br>
      &lt;%@ page import=&quot;org.apache.fop.apps.MimeConstants&quot; %&gt;</font></p>
    <p><font face="Courier New, Courier, mono" size="-1"><br>
      &lt;%<br>
      try {</font></p>
    <p><font face="Courier New, Courier, mono" size="-1"> FopFactory fopFactory 
      = FopFactory.newInstance();<br>
      <br>
      System.out.println(&quot;Chart2PDF\n&quot;);<br>
      <br>
      // files , <font color="#FF0000"><b>PLEASE MODIFY THE DIRECTORIES</b></font><br>
      File fofile = new File(&quot;C:\\java\\tomcat-5.0.19\\webapps\\rchart2\\chart.fo&quot;);<br>
      File pdffile = new File(&quot;C:\\java\\tomcat-5.0.19\\webapps\\rchart2\\Chart.pdf&quot;);</font></p>
    <p><font face="Courier New, Courier, mono" size="-1"> OutputStream out1 = 
      null; <br>
      FOUserAgent foUserAgent = fopFactory.newFOUserAgent();</font></p>
    <p><font face="Courier New, Courier, mono" size="-1"> // Setup output stream. 
      <br>
      out1 = new FileOutputStream(pdffile);<br>
      out1 = new BufferedOutputStream(out1);<br>
      Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out1);<br>
      // Setup JAXP using identity transformer<br>
      TransformerFactory factory = TransformerFactory.newInstance();<br>
      Transformer transformer = factory.newTransformer(); // identity transformer</font></p>
    <p><font face="Courier New, Courier, mono" size="-1"> // Setup input stream<br>
      Source src = new StreamSource(fofile);<br>
      // Resulting SAX events (the generated FO) must be piped through to FOP<br>
      Result res = new SAXResult(fop.getDefaultHandler());<br>
      <br>
      transformer.transform(src, res);</font></p>
    <p><font face="Courier New, Courier, mono" size="-1"> out1.close();<br>
      System.out.println(&quot;End\n&quot;);<br>
      } catch (Exception e) {<br>
      e.printStackTrace();<br>
      }</font></p>
    <p></p>
    <p><font face="Courier New, Courier, mono" size="-1"> // SEND RESPONSE PDF<br>
      response.setContentType(&quot;application/pdf&quot;);<br>
      response.sendRedirect(&quot;Chart.pdf&quot;);<br>
      // avoid caching in browser<br>
      response.setHeader (&quot;Pragma&quot;, &quot;no-cache&quot;);<br>
      response.setHeader (&quot;Cache-Control&quot;, &quot;no-cache&quot;);<br>
      response.setDateHeader (&quot;Expires&quot;,0);</font></p>
    <p><font face="Courier New, Courier, mono" size="-1"><br>
      %&gt;</font></p>
    <p>&nbsp;</p>
  </blockquote>
</blockquote>
<p><font face="Arial, Helvetica, sans-serif" size="-1"><b><a name="jsp"></a>JSP 
  Tag Library</b></font></p>
<blockquote> 
  <p>&nbsp;</p>
</blockquote>
<p><font face="Arial, Helvetica, sans-serif" size="-1">The JSP Tag library allows 
  you to add charts to a JSP page with almost no java programming. The following 
  steps show how to use the Tag libray:</font></p>
<ul>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">Copy examples_JSPTagLibrary\WEB-INF\jsp\j4lchart-tablig.tld 
    to tomcatdirectory\webapps\yourapplicationdirectory\WEB-INF\jsp</font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">Copy examples_JSPTagLibrary\WEB-INF\web.xml 
    to tomcatdirectory\webapps\yourapplicationdirectory\WEB-INF\web.xml</font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">Copy all rchart jar 
    files to tomcatdirectory\webapps\yourapplicationdirectory\WEB-INF\lib</font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">Create a new JSP called 
    tomcatdirectory\webapps\yourapplicationdirectory\rchart.jsp. </font> 
    <ul>
      <li><font face="Arial, Helvetica, sans-serif" size="-1">The file must include 
        the following line:<br>
        <br>
        <font face="Courier New, Courier, mono">&lt;%@ taglib uri=&quot;/WEB-INF/jsp/j4lchart-tablig.tld&quot; 
        prefix=&quot;j4lchart&quot; %&gt;</font><br>
        <br>
        </font> </li>
      <li><font face="Arial, Helvetica, sans-serif" size="-1">Now add the chart 
        to your JSP page, for example a complete JSP page is:<br>
        <br>
        <br>
        <font face="Courier New, Courier, mono">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD 
        HTML 4.0 Transitional//EN&quot;&gt;<br>
        &lt;HTML&gt;<br>
        &lt;HEAD&gt;<br>
        &lt;%@ taglib uri=&quot;/WEB-INF/jsp/j4lchart-tablig.tld&quot; prefix=&quot;j4lchart&quot; 
        %&gt;<br>
        &lt;BODY&gt;</font></font> 
        <p><font face="Courier New, Courier, mono" size="-1">&lt;%<br>
          String data=&quot;13|43|50|45|30|32|42&quot;;<br>
          %&gt;</font></p>
        <blockquote> 
          <p><font face="Courier New, Courier, mono" size="-1"><b>&lt;j4lchart:Chart 
            </b>chartName=&quot;MyFirstChart&quot; format=&quot;JPEG&quot; createMap=&quot;false&quot; 
            &gt;<br>
            <br>
            &lt;j4lchart:Parameter pname=&quot;WIDTH&quot;&gt;400&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;HEIGHT&quot;&gt;400&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;TITLECHART&quot;&gt;Sales 2007&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;XLABEL&quot;&gt;Month&lt;/j4lchart:Parameter&gt; 
            <br>
            &lt;j4lchart:Parameter pname=&quot;YLABEL&quot;&gt;Million $&lt;/j4lchart:Parameter&gt; 
            <br>
            &lt;j4lchart:Parameter pname=&quot;XAXIS_LABELS&quot;&gt;June|July|Aug.|Sept.|Oct.|Nov.|Dec.&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;SERIE_1&quot;&gt;Products&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;SERIE_STYLE_1&quot;&gt;0.2|RED|LINE&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;SERIE_FONT_1&quot;&gt;Arial|PLAIN|8&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;SERIE_COLOR_1&quot;&gt;RED&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;SERIE_POINT_COLOR_1&quot;&gt;RED&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;SERIE_DATA_1&quot;&gt;<b><font color="#FF0000">&lt;%=data%&gt;</font></b>&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;BIG_TICK_INTERVALX&quot;&gt;1&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;CHART_FILL&quot;&gt;YELLOW&lt;/j4lchart:Parameter&gt;<br>
            &lt;j4lchart:Parameter pname=&quot;YSCALE_MIN&quot;&gt;0&lt;/j4lchart:Parameter&gt;<br>
            <br>
            <b>&lt;/j4lchart:Chart&gt;</b></font></p>
        </blockquote>
        <p><font face="Courier New, Courier, mono" size="-1">&lt;/BODY&gt;<br>
          &lt;/HTML&gt;</font></p>
        <font face="Arial, Helvetica, sans-serif" size="-1"><br>
        <br>
        </font></li>
    </ul>
  </li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">Start your web server 
    and run the JSP</font></li>
</ul>
<p><font face="Arial, Helvetica, sans-serif" size="-1">As you can see the chart 
  tag has the following format:</font></p>
<ul>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">The name of the tag 
    is &lt;j4lchart:Chart</font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">It has the following 
    attributes: </font> 
    <ul>
      <li><font face="Arial, Helvetica, sans-serif" size="-1">chartName: any name 
        you want to give to the chart</font></li>
      <li><font face="Arial, Helvetica, sans-serif" size="-1">createMap: set it 
        to true if you need to enable tips and/or html links</font></li>
      <li><font face="Arial, Helvetica, sans-serif" size="-1">format: can be JPEG 
        (default) , PNG or GIF. Don't forget to copy the PNG anf GIF encoders 
        to the lib directory if you want to use the png or gif formats.</font></li>
    </ul>
  </li>
</ul>
<p><font face="Arial, Helvetica, sans-serif" size="-1"><br>
  The Chart Tag contains a nested Tag which has the following format:</font></p>
<ul>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">The name is &lt;j4lchart:Parameter</font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">It has only 1 attribute 
    called pname which is the RChart's parameter name</font></li>
  <li><font face="Arial, Helvetica, sans-serif" size="-1">You put the value of 
    the parameter in the Tag's body. As you can see in the example you can use 
    JSP variables of code in the tag's body.</font></li>
</ul>
<p><font face="Arial, Helvetica, sans-serif" size="-1">The RChart Tag library 
  will at runtime create a HTML IMG tag like this one:</font></p>
<p><font face="Courier New, Courier, mono" size="-1">&lt;IMG src='servlet/RChartServlet?CHARTID=1173777103290' 
  BORDER=0 NAME='MyFirstChart' &gt;</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="-1">as you can see it create 
  a call to RChart's servlet providing a CHARTID as parameter. This CHARTID references 
  an object stored in the web application context.</font></p>
<blockquote>
  <blockquote> 
    <p>&nbsp;</p>
  </blockquote>
</blockquote>
<hr>
<p>&nbsp;</p>
</body>
</html>
